<?php defined('SYSPATH') or die('No direct script access.');
$officefunctions = Helper_officefunctions::factory();
$thesystems      = Helper_thesystems::factory();
$mydatetime      = Helper_mydatetime::factory();
$display         = Helper_displayitems::factory();
?>
<?php $invoices_id = Arr::get($_GET,'invoices_id') ?>
<?php $values = $officefunctions->print_invoices($invoices_id) ?>
<?php $multistore = $thesystems->system_auth('accounting_multistores') ?>
<!-- <meta http-equiv="refresh" content="1; url=<?php //echo URL::base() ?>pos/invoice?kembali=<?php //echo Arr::get($_GET,'kembali') ?><?php echo (Arr::get($_GET,'kembali') == '0' ? '0' : '#openModalKembali') ?>">
 -->


<div class="">
	<div class="row-fluid">
		<div class="span6">
		<div style="width: 360px;"align="center">
		  <h3 style="margin-bottom:-15px;">DAILY FRESHMART</h3>
          <p>Slawi,Tegal<br />
          085627771888</p>
		</div>
			<div class="row-fluid">
            
		<table width="345" >
	 	   <tr>
			<td align="center" width="39"><div align="left"><small>No</small></div></td>
		    <td width="154"><small>Description</small></td>
		    <td width="34"><div align="center"><small>QTY</small></div></td>
		    <td align="right" width="98"><small>Amount</small></td>
				  </tr>
					<?php $number         = 1; ?>
					<?php $totaljumlah    = 0; ?>
					<?php $subtotal       = 0; ?>
					<?php $total_subtotal = 0; ?>
					<?php $total_qty      = 0; ?>
					<?php foreach($values as $value) { ?>
					<?php 
				  	$items     			= $value['items'];
						$totalitems     = $value['totalitems'];
						$ammounts       = $value['ammounts'];
						$discounts      = $value['discounts'];
						$globaldiscount = $values[0]['globaldiscount'];
						$totaljumlah    += $totalitems;
						$subtotal       = $totalitems * $ammounts - $discounts;
						$total_subtotal += $subtotal;
						$total_qty      += $totalitems;
				  ?>
				  <?php $type = $thesystems->system_auth('module_products_detail_type'); ?>
						<?php if($type == 'skus') { ?>
							<?php $table = 'skus'; ?>
							<?php $field = 'value'; ?>
						<?php } else { ?>
							<?php $table = 'ucts'; ?>
							<?php $field = 'name'; ?>
						<?php } ?>
					<tr>
						<td align="center"><div align="left"><strong><?php echo $number ?></strong></div></td>
						<td ><strong><?php echo $display->show_value($items,'prod'.$table,$field) ?></strong></td>
						<td><div align="center"><strong><?php echo $totalitems ?></strong></div></td>
					  <td align="right"><strong><?php echo number_format($ammounts,0) ?></strong></td>
					</tr>
					<?php $number++; ?>
					<?php } ?>
					<tr>
					  <td align="right" colspan="3">&nbsp;</td>
					  <td align="right">&nbsp;</td>
				  </tr>
					<tr>
						<td colspan="2" align="right"><small>Total</small></td>
					    <td align="right"><div align="center"><strong><?php echo $total_qty;  ?></strong></div></td>
				      <td align="right"><strong><?php echo number_format($total_subtotal,0) ?></strong></td>
					</tr>
					<tr>
					  <?php
					  $paid = $values[0]['paid'];
					  ?>
					  <td align="right" colspan="2"><small>Cash</small></td>
					  <td align="right">&nbsp;</td>
					  <td align="right"><strong><?php echo number_format($paid,0); ?></strong></td>
				  </tr>
					<tr>
						<td align="right" colspan="2"><small>Kembali</small></td>
						<td align="right">&nbsp;</td>
						<td align="right"><strong><?php echo number_format($total_subtotal - $globaldiscount,0) ?></strong></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td align="right" colspan="4"></td>
					</tr>
                    <tr>
                    	<td></td>
                        <td></td>
                    </tr>
				</table>
                <div class="span4">
					<table width="348">
                	<tr>
                 	 <td width="320" align="center"><strong><?php echo $mydatetime->mktime_from_sql($values[0]['datetime'],'H'.' : '.'m') ?> / <?php echo $mydatetime->mktime_from_sql($values[0]['datetime'],'d-m-y') ?> / DFM<?php echo $values[0]['invoicenumbers']; ?> / <?php echo $display->show_value($values[0]['users_id'],'users','fullname'); ?></strong></td>
                	  </tr>
                        <tr>
                            <td valign="top" colspan="4"><div align="center"><b>Terimakasih</b></div></td>
                        </tr>
					</table>
			  </div> 
				
		  </div>
		</div>
	</div>
</div>
























